package test.fresh.things.junit;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class ReliableClass {
	int var1 = 0;
	int var2 = 0;

	// test with and without constructor
	// public ReliableClass() {
	// System.out.println("ReliableClass() Constructor");
	// var1 = 10;
	// var2 = 20;
	// System.out.println("var1= " + var1);
	// System.out.println("var2= " + var2);
	// System.out.println("---------------\n");
	// }

	@BeforeClass
	public static void rootLoad() { // this method is always STATIC
		System.out.println("@BeforeClass method rootLoad()");
		System.out.println("This method executes once time.");
		System.out.println("---------------\n");
	}

	@Before
	public void load01() {
		System.out.println("@Before method load01()");
		System.out.println("old var1= " + var1);
		System.out.println("old var2= " + var2);

		System.out.println("Modify vars...");
		var1 = 100;
		var2 = 200;

		System.out.println("new var1= " + var1);
		System.out.println("new var2= " + var2);
		System.out.println("---------------\n");
	}

	@Before
	public void load02() {
		System.out.println("@Before method load02()");
		System.out.println("old var1= " + var1);
		System.out.println("old var2= " + var2);

		System.out.println("Modify vars...");
		var1 = 100000;
		var2 = 200000;

		System.out.println("new var1= " + var1);
		System.out.println("new var2= " + var2);
		System.out.println("---------------\n");
	}

	@Test(expected = InterruptedException.class)
	public void testMethod01() {
		System.out.println("Check in method 1");
		System.out.println("var1= " + var1);
		System.out.println("---------------\n");
	}

	@Test
	public void testMethod02() {
		System.out.println("Check in method 2");
		System.out.println("var2= " + var2);
		System.out.println("---------------\n");
	}

	@After
	public void release() {
		System.out.println("@After method release()");
		System.out.println("---------------\n");
	}

	@AfterClass
	public static void finalRelease() { // this method is always STATIC
		System.out.println("@AfterClass method finalRelease()");
		System.out.println("This method executes once time.");
		System.out.println("---------------\n");
	}

}
